<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */
// ------------------------------------------------------------------------

/**
 * CodeIgniter Header Helpers
 *
 * @package		CodeIgniter
 * @subpackage	Helpers
 * @category	Helpers
 * @author		Ricardo Oliveira
 * @link		http://studioprogramar.com.br
 */
// ------------------------------------------------------------------------

/**
 * get_acesso
 *
 * Evita acesso nao autorizao.
 *
 * @access	public
 */
if (!function_exists('get_acesso')) {

    function get_acesso($lvl = 3) {
        $ci =& get_instance();
        $sc_user = $ci->session->userdata('co_usuario');
        $sc_lvl = $ci->session->userdata('co_tipo_usuario');
        if (!$sc_user) {
            $rt = urlencode($ci->uri->uri_string());
            redirect('/?rtn=' . $rt, 'refresh');
        }
        if($sc_lvl != $lvl && $lvl != 0){
           echo 'Acesso negado.';
           exit;
        }
    }

}


/**
 * ajax_only
 *
 * Evita acesso nao autorizao.
 *
 * @access	public
 */
if (!function_exists('ajax_only')) {
    function ajax_only() {
        $ci =& get_instance();
        $aj_req = $ci->input->is_ajax_request();
        if (!$aj_req) {
            echo 'Acesso restrito!';
            exit;
        }
    }

}
// ------------------------------------------------------------------------
/* End of file dasboard_helper.php */
/* Location: ./application/helpers/dasboard_helper.php */